<!doctype html>
<html>
<head>
    <title>Sequence - Diagrams</title>
    <script src="../vendors/raphael-min.js"></script>
    <script src="../vendors/underscore-min.js"></script>
    <script src="../vendors/sequence-diagram-min.js"></script>
</head>
<body>
    <div id="diagram"></div>
    <script>
      var ipcRenderer = require('electron').ipcRenderer,
          fs = require('fs');

      ipcRenderer.on('sequence-render-start', function(event, options) {
          // Load input contents
          try{
              var inputContent = fs.readFileSync(options.inputPath, 'utf8');

              // Generate SVG version of sequence
              var diagram = Diagram.parse(inputContent);
              diagram.drawSVG("diagram", {theme: 'simple'});

              // Write out the svg file
              fs.writeFileSync(options.outputPath, document.getElementById('diagram').innerHTML);
          } catch(err){
                ipcRenderer.send('sequence-error', err.message);
          }

          ipcRenderer.send('sequence-render-finished');
      });
    </script>
</body>
</html>
